<?php

/*
# ------------------------------------------------------------------------
# JA Job Board Package
# ------------------------------------------------------------------------
# Copyright (C) 2004-2010 JoomlArt.com. All Rights Reserved.
# @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
# Author: JoomlArt.com
# Websites: http://www.joomlart.com - http://www.joomlancers.com.
# ------------------------------------------------------------------------
*/


  defined('_JEXEC') or die('Retricted Access');
  
  global $jbconfig, $option;  
  $tableList = JobBoardConstant::getFieldTypeList();  
  $controllerName = JRequest::getVar('view');
  $limited = JRequest::getVar('limited', 0);
  $active = "sectiontableheader";
  $inactive = "";
?>
<script type="text/javascript">
    function tableOrdering( order, dir, task ) {
        var form = "";
    	if( typeof(form) == 'undefined' )
    		form = document.emplForm;
        if ( typeof(form.filter_order) == 'undefined' )
        	form = document.emplForm;
        form.filter_order.value     = order;
        form.filter_order_Dir.value    = dir;
        form.task.value = task;
        form.view.value = 'japrofiles';
        form.submit();
    }
    
    function listItemTask( id, field, task ) {
        var f = document.adminForm;
        f.cid.value = id;
        f.boxchecked.value = 1;
        f.task.value = task;
        f.field.value = field;
        
        f.submit();
    }
    
    function submitbutton(pressbutton, number, formEmp){
    	if (pressbutton!='job_list_via_profiles')
    		formEmp.view.value = 'japrofiles';
    	else{
    		formEmp.view.value = 'jajobs';
    		formEmp.action = "<?php echo  JURI::root().'index.php?option=com_jajobboard&view=jajobs'; ?>";
    	}
    	
		formEmp.task.value = pressbutton;
		formEmp.submit();
    }
    
    function isEmployerChecked(formObj, isitchecked)
	{
		if (isitchecked == true){
			formObj.boxchecked.value++;
		}
		else {
			formObj.boxchecked.value--;
		}
	}
	
	function isEmployerChecked(formObj, isitchecked)
	{
		if (isitchecked == true){
			formObj.boxchecked.value++;
		}
		else {
			formObj.boxchecked.value--;
		}
	}

	function updateselectedprofiles(formObj,obj){
		if (!obj.checked){
			$('li_'+obj.value).removeClass('selected');
	//		obj.checked = false;
		}
		else{
			$('li_'+obj.value).addClass('selected');
	//		obj.checked = true;
		}
		
		formObj.selectedJobs.value = formObj.boxchecked.value + ' ' + profile_select_text;
		formObj.selectedJobs2.value = formObj.boxchecked.value + ' ' + profile_select_text;
	}
	
	function updateselectallprofiles(formObj,obj,num_obj){
		
		if (obj.checked)
			formObj.boxchecked.value = num_obj;
		else
			formObj.boxchecked.value = 0;
		
		for (i=0;i<num_obj;i++)
		{
			if (obj.checked)
				formObj.elements['cb'+i].checked = true;
			else
				formObj.elements['cb'+i].checked = false;
			updateselectedprofiles(formObj,formObj.elements['cb'+i]);
		}
		formObj.selectedJobs.value = formObj.boxchecked.value + ' ' + profile_select_text;
		formObj.selectedJobs2.value = formObj.boxchecked.value + ' ' + profile_select_text;
	}
</script>
<div id="jobboard-content">
<?php 
	$filter_location = JRequest::getVar('location_id','');
	$is_filter = false;
	$text = JText::_('Your search');
	if ($filter_location)
	{
		$is_filter = true;
		
		$text .= " ".JText::_("in")." <strong class='highlight'>".$filter_location."</strong>";
		
	}
	$text .= " ".JText::_("return")." ".count($this->all_items)." ".JText::_("profile(s)")." ";
	
	if ($is_filter)
		echo "<span class=\"ja-profilesearch-result\">".$text."</span>";
?>
<form name="emplForm" action="<?php echo JURI::root();?>index.php?option=com_jajobboard&view=japrofiles" method="post">    
	
	<!--	BEGIN: All Profile List-->
	<?php 
	if(!count($this->all_items)>0){
		echo JText::_('No employers are found!');
	} 
	elseif(isset($this->fieldlist) && count($this->fieldlist)>0){
		jimport('joomla.filesystem.file');
		$theme = JRequest::getVar('theme');
		if (!$theme)
			$theme = $jbconfig['general']->get('theme', 'default');
		$path_themes = dirname(__FILE__).DS.'themes'.DS.$theme.DS.'jalist-item.php';
		if(JFile::exists($path_themes)){
			if(file_exists(dirname(__FILE__).DS.'themes'.DS.$theme.DS.'style.css')){
		    	JHTML::stylesheet('style.css', "components/com_jajobboard/views/japrofiles/tmpl/themes/$theme/");
		    }	
			include $path_themes;					
		}		
		elseif(JFile::exists(dirname(__FILE__).DS.'themes'.DS.'default'.DS.'jalist-item.php')){
			if(file_exists(dirname(__FILE__).DS.'themes'.DS.'default'.DS.'style.css')){
		    	JHTML::stylesheet('style.css', "components/com_jajobboard/views/japrofiles/tmpl/themes/default/");
		    }	
			include dirname(__FILE__).DS.'themes'.DS.'default'.DS.'jalist-item.php';
		}
		elseif(JFile::exists(JPATH_FILE.DS.'components'.DS.'com_jajobboard'.DS.'views'.DS.'japrofiles'.DS.'tmpl'.DS.'themes'.DS.'default'.DS.'jalist-item.php')){
			if(file_exists(dirname(__FILE__).DS.'themes'.DS.'default'.DS.'style.css')){
		    	JHTML::stylesheet('style.css', "components/com_jajobboard/views/japrofiles/tmpl/themes/default/");
		    }	
			include JPATH_FILE.DS.'components'.DS.'com_jajobboard'.DS.'views'.DS.'japrofiles'.DS.'tmpl'.DS.'themes'.DS.'default'.DS.'jalist-item.php';
		}
	}
	?>
	<!--	END: All Profile List-->	
		
	<input type="hidden" name="option" value="<?php echo $this->lists['option']; ?>" />
	
    <input type="hidden" name="task" value="" id="task"/>
	<!--<input type="hidden" name="table_name" value="<?php echo $this->table_name;?>" />-->
	<input type="hidden" name="boxchecked" id="boxchecked" value="0" />
	<input type="hidden" name="filter_order" id="filter_order" value="<?php echo $this->lists['filter_order']; ?>" />
		<input type="hidden" name="filter_order_Dir" id="filter_order_Dir" value="<?php echo $this->lists['filter_order_Dir']; ?>" />
	<!--<input type="hidden" name="cid" value="" />-->
	<input type="hidden" name="field" value="" />
	<input type="hidden" name="layout" value="jalist" />
	<input type="hidden" name="Itemid" value="<?php echo JRequest::getInt('Itemid', 1000);?>" />
 </form>
</div>
<script type="text/javascript">
 	formObj = document.emplForm;
 </script>